#include "userMain.h"
#include "userKeyStruct.h"

/***************************************************
***AKey configure
****************************************************/
#define 	AKEY	0x01
#define		BKEY	0x02
#define		CKEY	0x03
#define		TICK_MAX	500
extern uint8_t AKeyValue;
extern uint8_t BKeyValue;
//extern uint8_t CKeyValue;
uint8_t userKeyValue = 0x00;

uint16_t AKeyMarkTick = 0;
const struct SeLongKeyElement AKeySe = {
    1,
    0,
    300,
    AKeyShortPressFunc,
    AKeyLongPressFunc,
};

struct SeLongKeyVariate VAKeySe = {
    &AKeyValue,&AKeyMarkTick,1,
};

void AKeyMarkTickFunc(uint8_t AddVal)
{
    if(AKeyMarkTick < TICK_MAX)
    {
       	AKeyMarkTick = AKeyMarkTick + AddVal;
    }
}

void AKeyShortPressFunc(void)
{
        //userIrSendFunc();
        userKeyValue = 0x01;
        userSendKeyInfoFunc();
        _NOP;
}

void AKeyLongPressFunc(void)
{
    userKeyValue = 0x02;
    userSendKeyInfoFunc();
    userBeepOnFunc();
    LED_DELAY;
    userBeepOffFunc();
    LED_DELAY;
    userBeepOnFunc();
    LED_DELAY;
    userBeepOffFunc();
    _NOP;
}
/***************************************************
***BKey configure
****************************************************/
uint16_t BKeyMarkTick = 0;
const struct SeLongKeyElement BKeySe = {
    1,
    0,
    300,
    BKeyShortPressFunc,
    BKeyLongPressFunc,
};

struct SeLongKeyVariate VBKeySe = {
    &BKeyValue,&BKeyMarkTick,1,
};

void BKeyMarkTickFunc(unsigned char AddVal)
{
    if(BKeyMarkTick < TICK_MAX)
    {
       	BKeyMarkTick = BKeyMarkTick + AddVal;
    }
}

void BKeyShortPressFunc(void)
{
    userKeyValue = 0x03;
    userSendKeyInfoFunc();
    userBeepOnFunc();
    LED_DELAY;
    userBeepOffFunc();
    _NOP;
}

void BKeyLongPressFunc(void)
{
    userKeyValue = 0x04;
    userSendKeyInfoFunc();
    userBeepOnFunc();
    LED_DELAY;
    userBeepOffFunc();
    LED_DELAY;
    userBeepOnFunc();
    LED_DELAY;
    userBeepOffFunc();
    _NOP;
}


